package vista;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;

import javax.swing.WindowConstants;
import javax.swing.table.AbstractTableModel;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VentanaSeleccionarListaRegalo extends javax.swing.JFrame {
	private JPanel panCombos;
	private JPanel panLista;
	private JButton cmdSalir;
	private JLabel lblTitulo1;
	private JLabel lblTitulo;
	private JScrollPane scpObsequios;
	private JButton cmdAgregar;
	private JComboBox cmbProducto;
	private JLabel lblProducto;
	private JLabel lblTienda;
	private JComboBox cmbTienda;
	private JSplitPane jSplitPane1;
	private JTable tblObsequios;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				VentanaSeleccionarListaRegalo inst = new VentanaSeleccionarListaRegalo();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public VentanaSeleccionarListaRegalo() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setTitle("Lista de Obsequios");
			{
				jSplitPane1 = new JSplitPane();
				getContentPane().add(jSplitPane1, BorderLayout.CENTER);
				jSplitPane1.setPreferredSize(new java.awt.Dimension(692, 379));
				{
					panCombos = new JPanel();
					jSplitPane1.add(panCombos, JSplitPane.LEFT);
					panCombos.setPreferredSize(new java.awt.Dimension(300, 377));
					panCombos.setLayout(null);
					{
						lblTienda = new JLabel();
						panCombos.add(lblTienda);
						lblTienda.setText("Tienda");
						lblTienda.setBounds(33, 90, 75, 15);
					}
					{
						ComboBoxModel cmbTiendaModel = 
								new DefaultComboBoxModel(
										new String[] {"Seleccione una Tienda"});
						cmbTienda = new JComboBox();
						panCombos.add(cmbTienda);
						cmbTienda.setModel(cmbTiendaModel);
						cmbTienda.setBounds(126, 86, 147, 22);
					}
					{
						lblProducto = new JLabel();
						panCombos.add(lblProducto);
						lblProducto.setText("Producto");
						lblProducto.setBounds(33, 141, 75, 15);
					}
					{
						ComboBoxModel cmbProductoModel = 
								new DefaultComboBoxModel(
										new String[] { "Seleccione una Tienda" });
						cmbProducto = new JComboBox();
						panCombos.add(cmbProducto);
						cmbProducto.setModel(cmbProductoModel);
						cmbProducto.setBounds(126, 137, 147, 22);
					}
					{
						cmdAgregar = new JButton();
						panCombos.add(cmdAgregar);
						cmdAgregar.setText("Agregar");
						cmdAgregar.setBounds(39, 202, 102, 22);
					}
					{
						lblTitulo1 = new JLabel();
						panCombos.add(lblTitulo1);
						lblTitulo1.setText("Agregar producto a la lista");
						lblTitulo1.setBounds(71, 30, 217, 15);
					}
					{
						cmdSalir = new JButton();
						panCombos.add(cmdSalir);
						cmdSalir.setText("Salir");
						cmdSalir.setBounds(158, 202, 102, 22);
					}
				}
				{
					panLista = new JPanel();
					jSplitPane1.add(panLista, JSplitPane.RIGHT);
					panLista.setLayout(null);
					{
						scpObsequios = new JScrollPane();
						panLista.add(scpObsequios);
						scpObsequios.setBounds(12, 65, 361, 230);
						{
							tblObsequios = new JTable();
							scpObsequios.setViewportView(tblObsequios);
						}
					}
					{
						lblTitulo = new JLabel();
						panLista.add(lblTitulo);
						lblTitulo.setText("Lista de Obsequios");
						lblTitulo.setBounds(133, 28, 208, 15);
					}

				}
				
			}
			pack();
			this.setSize(706, 339);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	public void agregarListener(ActionListener actionListener) {
		this.cmbTienda.addActionListener(actionListener);
		this.cmdAgregar.addActionListener(actionListener);
		this.cmdSalir.addActionListener(actionListener);
	}
	
	public void setTiendas(String[] tiendas) {
		ComboBoxModel cmbTiendasModel = new DefaultComboBoxModel(tiendas);
		cmbTienda.setModel(cmbTiendasModel);
	}
	
	public void setProductos(String[] productos) {
		ComboBoxModel cmbProductosModel = new DefaultComboBoxModel(productos);
		cmbProducto.setModel(cmbProductosModel);
	}
	
	public void mostrarMensaje(String mensaje) {
		JOptionPane.showMessageDialog(this, mensaje);
	}

	public JComboBox getCmbProducto() {
		return cmbProducto;
	}

	public void setCmbProducto(JComboBox cmbProducto) {
		this.cmbProducto = cmbProducto;
	}

	public JComboBox getCmbTienda() {
		return cmbTienda;
	}
	
	public String getTiendaCmb() {
		return cmbTienda.getSelectedItem().toString();
	}
	
	public String getProductoCmb() {
		return cmbProducto.getSelectedItem().toString();
	}
	

	public void setCmbTienda(JComboBox cmbTienda) {
		this.cmbTienda = cmbTienda;
	}
	
	public void setListado(AbstractTableModel abstractTableModel){
		
		tblObsequios.setModel(abstractTableModel);
	}

	public void setTiendasComboBox(List<String> nombre) {
		
		cmbTienda.removeAll();
		//cmbTienda.addItem("Seleccione una opcion");
		for(int i = 0; i < nombre.size();i++){
			cmbTienda.addItem(nombre.get(i));
		}
		
		
	}
	
public void setTiendasComboBoxProducto(List<String> nombre) {
		
		cmbTienda.removeAll();
		//cmbTienda.addItem("Seleccione una opcion");
		for(int i = 0; i < nombre.size();i++){
			cmbProducto.addItem(nombre.get(i));
		}

	}
	

}
